# -*- codeing = utf-8 -*-
# @Time : 2021/2/27 21:13
# @Atuthor: 朱朱
# @File: 140练习3.py
# @Software: PyCharm

class Petshop(object): # 定义一个宠物商店类
    def __init__(self, shop_name, pet_list = None):
        self.shop_name = shop_name
        if pet_list is None:
            pet_list=[]
        self.pet_list = pet_list

    def show_pets(self):
        if len(self.pet_list) == 0:
            print('本店还没有宠物')
            return
        print(f'{self.shop_name}有{len(self.pet_list)}个宠物,它们是:{self.pet_list} ')

class Pet(object): # 定义一个宠物类
    def __init__(self,name, gender, age, breed):
        self.name = name
        self.gender = gender
        self.age = age
        self.breed = breed

    def bark(self):
        print(self.name + '正在叫...')

    def eat(self):
        print(self.name + '正在吃...')

    def __repr__(self):
        return f'名字{self.name},性别{self.gender},年龄:{self.age},品种:{self.breed}'

class PetDog(Pet):
    def bark(self):
        print(self.name+ '正在汪汪汪....')
    def build_home(self):
        print(self.name + '正在拆家')
    def eat(self):
        print(self.name+'正在啃骨头')

class PetCat(Pet):
    def __init__(self, name, gender, age, breed,eyes_color):
        super(PetCat, self).__init__(name,gender,age,breed)
        self.eyes_color = eyes_color

    def bark(self):
        print(self.name+ '正在喵喵喵.....')

    def coquetry(self):
        print(self.name+'正在撒娇....')

    def eat(self):
        print(self.name+'正在吃鱼....')

    def __repr__(self):
        x = super(PetCat, self).__repr__()
        x += f',眼睛颜色:{self.eyes_color}'
        return x

class PetBird(Pet):
    pass

dog1 = PetDog('jack','female',3,'hashiqi')
dog2 = PetDog('tony','male',4,'samo')
cat1 = PetCat('tom','female',3,'edou','blue')
cat2 = PetCat('luck','male',4, 'kafei', 'black')
dog1.build_home()
ps = Petshop('萌宠',[dog1,dog2,cat1,cat2])
ps.show_pets()
print(dog1) # 应用repr方法打印
print(cat1)